/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;
import Interfaces.Name;

/**
 *
 * @author markusbaisch
 */
public class NameImpl implements Name {

    private final String name;

    // Konstruktor
    private NameImpl(String name ) {
        this.name = name;
    }

    static Name valueOf( String name ) {
        return new NameImpl( name );
    }

    // Rest
    @Override
    public String nameString() {
        return name;
    }

    public int compareTo( Name Value ) {
        return name.compareTo( Value.nameString() );
    }

    @Override
    public boolean equals( Object obj ) {
        if( this == obj ) return true;
        if (!(obj instanceof Name)) return false;
        return compareTo((Name) obj) == 0;
    }

    @Override
    public int hashCode() {
        return name.hashCode() * name.hashCode();
    }
}
